package org.com.yz.dubbo.web.impl;

import org.com.yz.common.util.MyLog;
import org.com.yz.dal.dao.mapper.BankCardMapper;
import org.com.yz.dal.dao.mapper.DepositTransactionMapper;
import org.com.yz.dal.dao.model.BankCard;
import org.com.yz.dal.dao.model.DepositTransaction;
import org.com.yz.dubbo.web.service.CheckTransService;
import org.com.yz.dubbo.web.service.CheckWithDrawService;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 校验提现相关信息实现类
 */
@Service
public class CheckWithDrawServiceImpl implements CheckWithDrawService {

    private static final MyLog _log = MyLog.getLog(CheckWithDrawServiceImpl.class);

    @Autowired
    private BankCardMapper bankCardMapper;


    @Override
    public boolean checkCardNo(String cardNo, String mchAccntNo, String mchNo) {
        BankCard bankCard = new BankCard();
        bankCard.setCardNo(cardNo);
        bankCard.setMchAccntNo(mchAccntNo);
        bankCard.setMchNo(mchNo);
        bankCard.setStatus("success");
        List<BankCard> list = bankCardMapper.select(bankCard);
        if (list.size() > 0) {
            return true;
        }
        return false;
    }

    @Override
    public BankCard checkNostro(String cardNo, String mchAccntNo, String mchNo, String isSuccessFlag) {
        BankCard bankCard = new BankCard();
        bankCard.setCardNo(cardNo);
        bankCard.setMchAccntNo(mchAccntNo);
        bankCard.setMchNo(mchNo);
        if ("1".equals(isSuccessFlag)) {
            bankCard.setStatus("success");
        }
        List<BankCard> list = bankCardMapper.select(bankCard);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }


    @Override
    public BankCard selectBankCardInfo(String cardNo, String mchAccntNo, String mchNo) {
        BankCard bankCard = new BankCard();
        bankCard.setCardNo(cardNo);
        bankCard.setMchAccntNo(mchAccntNo);
        bankCard.setMchNo(mchNo);
        List<BankCard> list = bankCardMapper.select(bankCard);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

}
